home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
editors
/
ted15
/
tfix.pas
< prev
Wrap
Pascal/Delphi Source File
|
1987-04-13
|
3KB
|
92 lines
Program TFix;
{$I-}
Type
Str2 = String[2];
Str8 = String[8];
Str16 = String[16];
FileName = String[64];
FileRec = record
Ch: Char;
End;
Var
TedFile : File of FileRec;
TedRec : FileRec;
Name1 : FileName;
I,DecBytes : Integer;
Ans : Char;
HexBytes,Work : Str2;
Function HexStrToDec(HexStr:Str8):Real;
Var HexChars : Str16;
R: Real;
Procedure Compute(CompI: Real; CompJ: Integer);
Begin
R := ((Pos(HexStr[CompJ],HexChars)-1)*CompI) + R;
If CompJ <> 1 then Compute(CompI*16,CompJ-1);
End; { Compute }
Begin { I = incrementor }
HexChars := '0123456789ABCDEF'; { J = pos in string }
R := 0.0;
Compute(1,Length(HexStr));
HexStrToDec := R;
End; { HexStrToDec }
Function DecToHexStr(Val:Integer):Str2;
Const Digits : Array [ 0..15 ] of Char = '0123456789ABCDEF';
Begin
DecToHexStr := Digits[ Val Div 16 ] +
Digits[ Val Mod 16 ];
End; { Hex }
BEGIN
TedRec.Ch := ' ';
ClrScr;
GotoXY(1,5);
WriteLn('This program will modify the stack/heap size of a Turbo Pascal');
WriteLn('program. It saves recompiling the program but beware, it modifies');
WriteLn('the COM file and changes the size in 64K increments. If the value');
WriteLn('entered is not a valid Hex digit then ''A'' is used.');
WriteLn;
Write('Turbo COM file name: ');
Readln(Name1); WriteLn;
Assign(TedFile,Name1);
Reset(TedFile);
If IOResult <> 0 then begin
Close(TedFile);
Writeln('Error -- From file not found: ',Name1);
Halt;
End;
With TedRec do begin
(* I := 11404; { 11403 } { TURBO 3.01 }*)
I := 11357; { 11356 } { TURBO 3.01B }
Seek(TedFile,I); { Goto location to patch }
Read(TedFile,TedRec);
Work := DecToHexStr(Lo(Ord(Ch)));
WriteLn('Currect stack/heap size(hex) = ',Copy(Work,1,1),' 64K blocks.');
Seek(TedFile,I);
WriteLn;
Write('Max. Stack/Heap size Bytes: ');
Read(HexBytes);
For I := 1 to Length(HexBytes) do HexBytes[I] := UpCase(HexBytes[I]);
HexBytes := HexBytes + '0';
If Not (HexBytes[I] in ['0'..'9']) and Not (HexBytes[I] in ['A'..'F']) then
HexBytes[I] := 'A';
Ch := Chr(Ord(Trunc(HexStrToDec(Copy(HexBytes,1,2)))));
{ Setup byte }
Write(TedFile,TedRec); { Patch in max. stack/heap size }
Close(TedFile); { We're Done }
WriteLn;
WriteLn;
WriteLn(Name1,' Modified!');
End;
End.